/*
Project: 		The Impact of Short-Term Employment for Low-Income Youth: Experimental 	
				Evidence from the Philippines
Authors: 		Emily A. Beam and Stella Quimbo

***********************************
Path: 			code/02_analysis
File name: 		table_a10.do 
***********************************

Purpose: 		Generates Appendix Table A10: Relationship between SPES program tasks and endline employment, controlling for student characteristics

Inputs: 		spes_data.dta
Outputs: 		table_a10.tex

Log: 			results/03_output/log_table_a10.log		

Last updated: 	18 November 2021
*/



cap log close 
log using "$output/log_table_a10.log",replace



use "$usedata_analysis/spes_data.dta", clear
keep if endline == 1


recode _spes_tasks1 -222 = 16
recode _spes_tasks2 -222 = 16

forval number = 1/16{
	di `number'
	gen _anytask`number' = _spes_tasks1 == `number' | _spes_tasks2 == `number'
	replace _anytask`number' = . if missing(_spes_tasks1)
}


lab var _anytask1 "Encoding"
lab var _anytask2 "Typing"
lab var _anytask3 "Filing and organizing"
lab var _anytask4 "Copying and scanning"
lab var _anytask5 "Processing forms"
lab var _anytask6 "Cleaning and planting"
lab var _anytask7 "Surveying"
lab var _anytask8 "Surveying (agri.)"
lab var _anytask9 "Messenger"
lab var _anytask10 "Maintaining cleanliness"
lab var _anytask11 "Teaching"
lab var _anytask12 "Caregiving"
lab var _anytask13 "Charity work"
lab var _anytask14 "Customer service"
lab var _anytask15 "Manual tasks"
lab var _anytask16 "Other"

lab var treatment "Invited to SPES"
lab var _bb_edulvl "College"



local n: word count $cov1
	assert `n' == 18 


		areg _eeo_worknow treatment $cov1 _anytask* if treatment!=. ,r absorb(scel)
		estimates store tasks
		summ _eeo_worknow if treatment==0 
			estadd scalar dmean = `r(mean)'
		
		testparm _anytask*
			local pval = `r(p)'
			estadd scalar pvalint = `r(p)'	
	
cd "$tables_analysis"
		
		#delimit ;
		
	esttab tasks 			  
	using table_a10.tex, replace star(* 0.10 ** 0.05 *** 0.01) 
	cells("b(fmt(3) star)" "se(par([ ]))") 
	stats(N dmean pvalint, fmt(%9.0f %9.3f %9.3f )  
	labels( "Observations" "Mean, control group" "p-value, joint significance")) 
	keep(treatment _bb_edulvl _anytask*) label  varwidth(16) modelwidth(13) style(tex) 
	title(Relationship between work tasks and endline employment\label{teduc}) 
	varlabels(_cons Constant) 
	mlabels("Currently Working"  ,
			span prefix(\multicolumn{@span}{p{0.15\textwidth}}{) suffix(})) 
	collabels(none)
	prehead(  "\begin{tabular}{p{0.4\textwidth}p{0.15\textwidth}}" "\toprule") 
	posthead(\hline) prefoot() postfoot("\bottomrule" "\end{tabular}" );

	
	log close; 
	exit; 
